/**
 * @file contests/cf1702/c/main.cpp
 * @brief
 * @see
 * @author Ruiming Guo (guoruiming@stu.scu.edu.cn)
 * @copyright 2022
 * @date 2022/7/10 22:03:14
 **/

#include <iostream>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const int N = 2e5 + 10;
int main() {
  // High rating and good luck!
  int tc;
  cin >> tc;
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  while (tc--) {
    int n, k;
    cin >> n >> k;
    unordered_map<int, int> first, last;
    for (int i = 1; i <= n; ++i) {
      int a;
      cin >> a;
      if (!first[a]) first[a] = i;
      last[a] = i;
    }
    while (k--) {
      int a, b;
      cin >> a >> b;
      cout << (first.count(a) && last.count(b) && first[a] <= last[b] ? "YES\n"
                                                                      : "NO\n");
    }
  }
  return 0;
}
